﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;

namespace MvvmOrm.Tests
{
    static class Common
    {
        public static readonly string ResourcesPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Resources");
        public static readonly string SchemaSqlite = Path.Combine(ResourcesPath, "db_create_sqlite.txt");
        public static readonly string SavedFile = Path.Combine(ResourcesPath, "MvvmOrm.Models.mo");

        public static Models.MainViewModel PrepareSqliteContext()
        {
            Models.MainViewModel mainViewModel = new Models.MainViewModel();
            mainViewModel.OpenNewCmd.Execute();
            var db = mainViewModel.DB;
            db.UseSchemaFile = true;
            db.SchemaFile = SchemaSqlite;
            return mainViewModel;
        }

        public static string GetTemporaryDirectory()
        {
            string tempDirectory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
            Directory.CreateDirectory(tempDirectory);
            return tempDirectory;
        }
    }
}
